def is_valid_brackets(sequence):
    stack = []
    opening_brackets = "([{<"
    closing_brackets = ")]}>"
    for bracket in sequence:
        if bracket in opening_brackets:
            stack.append(bracket)
        elif bracket in closing_brackets:
            if len(stack) == 0:
                return False
            last_opening_bracket = stack.pop()
            if opening_brackets.index(last_opening_bracket) != closing_brackets.index(bracket):
                return False
    if len(stack) > 0:
        return False
    return True
sequences = input().split()
for sequence in sequences:
    if is_valid_brackets(sequence):
        print(sequence + " - true")
    else:
        print(sequence + " - false")